import common from './common'

const api = {
  testMock: 'mock/test',
  createDataQualityConfig: 'data/quality/config/createDataQualityConfig', // 创建数据质检配置
  listConfigFormByConfigId: 'data/quality/config/listConfigFormByConfigId', // 根据配置id获取其所拥有的表单列表
  listConfigFormItemByConfigFormId: 'data/quality/config/listConfigFormItemByConfigFormId', // 根据配置表单d获取其所拥有的字段列表
  addConfigForm: 'data/quality/config/addConfigForm', // 为已存在的配置添加新的表单(同时解析表单字段)
  deleteConfigFormById: 'data/quality/config/deleteConfigFormById', // 根据表单配置id批量删除
  deleteFormItemById: 'data/quality/config/deleteFormItemById', // 根据表单字段id删除对应配置
  updateConfigFormItem: 'data/quality/config/updateConfigFormItem', // 更新表单字段信息
  updateConfig: 'data/quality/config/updateConfig', // 更新配置名称和描述
  deleteConfigById: 'data/quality/config/deleteConfigById', // 删除对应配置
  listScriptItemByFormItemId: 'data/quality/config/listScriptItemByFormItemId', // 获取表单自定义脚本列表
  saveScriptItem: 'data/quality/config/saveScriptItem', // 保存表单自定义脚本列表
  deleteScriptItemById: 'data/quality/config/deleteScriptItemById', // 删除自定义脚本
  getConfigFormByConfigFormId: 'data/quality/config/getConfigFormByConfigFormId', // 根据Id获取表单信息
  updateConfigForm: 'data/quality/config/updateConfigForm', // 更新表单基本信息
  startCheck: 'data/quality/check/startCheck', // 执行数据校验
  initDataQualityFormByCfgFormId: 'data/quality/config/initDataQualityFormByCfgFormId' // 根据表单配置d更新其对应字段信息
}

const dataService = {};

(service => {
  service.testMock = (data) => {
    return common.get(api.testMock, data)
  }
  service.createDataQualityConfig = (data) => {
    return common.post(api.createDataQualityConfig, null, data)
  }
  service.listConfigFormByConfigId = (params) => {
    return common.get(api.listConfigFormByConfigId, params)
  }
  service.listConfigFormItemByConfigFormId = (params) => {
    return common.get(api.listConfigFormItemByConfigFormId, params)
  }
  service.addConfigForm = (params, data) => {
    return common.post(api.addConfigForm, params, data)
  }
  service.deleteConfigFormById = (params) => {
    return common.post(api.deleteConfigFormById, params)
  }
  service.deleteFormItemById = (params) => {
    return common.post(api.deleteFormItemById, params)
  }
  service.updateConfigFormItem = (data) => {
    return common.post(api.updateConfigFormItem, null, data)
  }
  service.updateConfig = (data) => {
    return common.post(api.updateConfig, null, data)
  }
  service.deleteConfigById = (params) => {
    return common.post(api.deleteConfigById, params)
  }
  service.listScriptItemByFormItemId = (params) => {
    return common.get(api.listScriptItemByFormItemId, params)
  }
  service.saveScriptItem = (data) => {
    return common.post(api.saveScriptItem, null, data)
  }
  service.deleteScriptItemById = (params) => {
    return common.post(api.deleteScriptItemById, params)
  }
  service.getConfigFormByConfigFormId = (params) => {
    return common.get(api.getConfigFormByConfigFormId, params)
  }
  service.updateConfigForm = (data) => {
    return common.post(api.updateConfigForm, null, data)
  }
  service.startCheck = (params, data) => {
    return common.post(api.startCheck, params, data)
  }
  service.initDataQualityFormByCfgFormId = (params) => {
    return common.post(api.initDataQualityFormByCfgFormId, params)
  }
})(dataService)

export default dataService
